import Vue from 'vue'
import Router from 'vue-router'
import Register from '@/components/Register'
import Bar from '@/components/Bar'
import Ask from '@/components/Ask'
import fillDurg from '@/components/fillDurg'
import Doctor from '@/components/Doctor'
import doctorList from '@/components/doctorList'
import answer from '@/components/answer'
import Case from '@/components/case'
import doctorComment from '@/components/doctorComment'
import feedback from '@/components/feedback' 
import inquirySingle from '@/components/inquirySingle'
import question from '@/components/question'
import map from '@/components/map'
import buyDurg from '@/components/buyDurg'
import doctorDetail from '@/components/doctorDetail'
import durgIntro from '@/components/durgIntro'
import address from '@/components/address'
import addAddress from '@/components/addAddress'
import recipe from '@/components/recipe'  
import approve from '@/components/approve'
import reword from '@/components/reword'

Vue.use(Router)

const router = new Router({
  routes: [
    {
      path: '/',
      name: 'ask',
      component: Ask
    },
    {
      path: '/register',
      name: 'register',
      meta:{
        title:'与小禾对话中'
      },
      component: Register
    },
    {
      path: '/ask',
      name: 'ask',
      meta:{
        title:'咨询问诊'
      },
      component: Ask
    },
    {
      path: '/fillDurg',
      name: 'fillDurg',
      component: fillDurg,
      meta:{
        title:'订单'
      },
    },
    {
      path: '/doctor',
      name: 'doctor',
      meta:{
        title:'找名医',
        keepAlive: true
      },
      component: Doctor
    },
    {
      path: '/doctorDetail/:id',
      name: 'doctorDetail',
      meta:{
        title:'医生详情',
      },
      component: doctorDetail
    },
    {
      path: '/doctorList/:keyword',
      name: 'doctorList',
      meta:{
        title:'名医列表'
      },
      component: doctorList
    },
    {
      path: '/answer',
      name: 'answer',
      meta:{
        title:'答卷'
      },
      component: answer
    },
    {
      path: '/case',
      name: 'case',
      meta:{
        title:'我的病例'
      },
      component: Case
    },{
      path: '/doctorComment/:id',
      name: 'doctorComment',
      meta:{
        title:'评价'
      },
      component: doctorComment  
    },
    {
      path: '/feedback',
      name: 'feedback',
      meta:{
        title:'反馈'
      },
      component: feedback 
    },
    {
      path:'/inquirySingle',
      name:'inquirySingle',
      meta:{
        title:'填写问诊单'
      },
      component:inquirySingle
    },
    {
      path:'/question',
      name:'question',
      meta:{
        title:'医生问题'
      },
      component:question
    },
    {
      path:'/map',
      name:'map',
      meta:{
        title:'地图'
      },
      component:map
    },
    {
      path:'/buyDurg',
      name:'buyDurg',
      meta:{
        title:'购药'
      },
      component:buyDurg
    },
    {
      path:'/durgIntro',
      name:'durgIntro',
      meta:{
        title:'药态'
      },
      component:durgIntro
    },
    {
      path:'/address',
      name:'address',
      meta:{
        title:'我的收货地址'
      },
      component:address
    },
    {
      path:'/addAddress',
      name:'addAddress',
      meta:{
        title:'新增地址'
      },
      component:addAddress
    },
    {
      path:'/recipe',
      name:'recipe',
      meta:{
        title:'医生处方'
      },
      component:recipe
    },
    {
      path:'/approve',
      name:'approve',
      meta:{
        title:'认证'
      },
      component:approve
    },
    {
      path:'/reword',
      name:'reword',
      meta:{
        title:'问诊'
      },
      component:reword
    },
  ],
})
router.beforeEach((to, from, next) => {
  /* 路由发生变化修改页面title */
  if (to.meta.title) {
    document.title = to.meta.title;
  }
  next();
})

export default router;
